package com.xtm.exercise.base.A12JUC;

import org.junit.Test;

import java.util.concurrent.TimeUnit;

/***
 *@Author: 王磊
 *@CreateTime: 2023-09-10  22:55
 *@Description: TODO
 *@title: TestJuc
 */
public class TestJuc {

    @Test
    public void TimeUnit(){

        // 睡几秒 , TimeUnit 与 Thread.sleep 作用相同，只是写法不同，前者可读性更好
        try {
            System.out.println("准备睡");

            TimeUnit.SECONDS.sleep(4000);
            Thread.sleep(4000);

            System.out.println("睡4秒后，执行");
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }

    }
}
